package domain.model;

import java.util.ArrayList;
import java.util.Date;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.Text;

@PersistenceCapable
public class TrackIp {
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	@PrimaryKey
	private Key key;
	@Persistent
	private String ip;
	@Persistent
	private String jsp;
	@Persistent
	private String organization;
	@Persistent
	private String proxy;
	@Persistent
	private String type;
	@Persistent
	private String assignment;
	@Persistent
	private String country;
	@Persistent
	private String state;
	@Persistent
	private String city;
	@Persistent
	private String cron;
	@Persistent
	private Text whoisIp;
	@Persistent
	private Date date;
	@Persistent
	private ArrayList<String> domain = new ArrayList<String>();
	public Text getWhoisIp() {
		return whoisIp;
	}
	public void setWhoisIp(Text whoisIp) {
		this.whoisIp = whoisIp;
	}
	public void addDomain(String domain)
	{
		if(!this.domain.contains(domain))
			this.domain.add(domain);
	}
	public String getDomainString()
	{
		String str="";
		int i = 0;
		for(String domain : this.getDomain())
		{
			i++;
			str+="<li><a href=\"/domain/"+domain+"\">"+domain+"</a></li>";
			if(i > 20)
				break;
			
		}
		return str;
	}
	public String getDomainStrings()
	{
		String str="";
		int i = 0;
		for(String domain : this.getDomain())
		{
			i++;
			str+="<a href=\"/domain/"+domain+"\">"+domain+"</a> , ";
			if(i > 20)
				break;
			
		}
		return str;
	}
	public ArrayList<String> getDomain() {
		return domain;
	}
	public void setDomain(ArrayList<String> domain) {
		this.domain = domain;
	}
	public String getCron() {
		return cron;
	}
	public void setCron(String cron) {
		this.cron = cron;
	}
	public Key getKey() {
		return key;
	}
	public void setKey(Key key) {
		this.key = key;
	}
	public String getIp() {
		return ip;
	}
	public void setIp(String ip) {
		this.ip = ip;
	}
	public String getJsp() {
		return jsp;
	}
	public void setJsp(String jsp) {
		this.jsp = jsp;
	}
	public String getOrganization() {
		return organization;
	}
	public void setOrganization(String organization) {
		this.organization = organization;
	}
	public String getProxy() {
		return proxy;
	}
	public void setProxy(String proxy) {
		this.proxy = proxy;
	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	public String getAssignment() {
		return assignment;
	}
	public void setAssignment(String assignment) {
		this.assignment = assignment;
	}
	public String getCountry() {
		return country;
	}
	public void setCountry(String country) {
		this.country = country;
	}
	public String getState() {
		return state;
	}
	public void setState(String state) {
		this.state = state;
	}
	public String getCity() {
		return city;
	}
	public void setCity(String city) {
		this.city = city;
	}
	public Date getDate() {
		return date;
	}
	public void setDate(Date date) {
		this.date = date;
	}

}
